2.


In [1]:
import pandas as pd

In [5]:
import datetime

In [2]:
data = pd.read_table('daily_weather.tsv')

convert date column to a datetime object


In [8]:
for i, row in enumerate(data['date']):
        data.set_value(i, 'date', datetime.datetime.strptime(row, '%Y-%m-%d').date())

make a column for the month


In [10]:
for i, row in enumerate(data['date']):
    data.set_value(i, 'month', row.month)

sort by month column, print the mean of the temp column


In [12]:
data.groupby('month')['temp'].mean()


Out[12]:
month
1     0.275181
2     0.315337
3     0.449411
4     0.468809
5     0.612366
6     0.675111
7     0.752366
8     0.711801
9     0.620083
10    0.500049
11    0.336101
12    0.322880
Name: temp, dtype: float64